package zq.cn.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import utils.Globals;

public class InitActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_init);

        Thread t = new Thread() {
            @Override
            public void run() {
                Globals.init(InitActivity.this);
                SharedPreferences sp = getSharedPreferences("game" +
                        "",MODE_PRIVATE);
                if(sp.getInt("nowStage", 0)==0) {
                    SharedPreferences.Editor e = sp.edit();
                    e.putInt("nowStage", 1);
                    e.putInt("coin",100);
                    e.commit();
                }
                try {
                    sleep(2000);

                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                Intent in = new Intent(InitActivity.this, MainActivity.class);
                startActivity(in);

                finish();
            }
        };

        t.start();
    }
}
